home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWMenu / FWMnuBar.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  19.4 KB  |  604 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWMnuBar.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWMNUBAR_H
  13. #include "FWMnuBar.h"
  14. #endif
  15.  
  16. #ifndef FWPULLDM_H
  17. #include "FWPullDM.h"
  18. #endif
  19.  
  20. // ----- Foundation Includes -----
  21.  
  22. #ifndef FWSTRS_H
  23. #include "FWStrs.h"
  24. #endif
  25.  
  26. #ifndef FWSOMENV_H
  27. #include "FWSOMEnv.h"
  28. #endif
  29.  
  30. // ----- OS Includes -----
  31.  
  32. #ifndef FWRESOUR_H
  33. #include "FWResour.h"
  34. #endif
  35.  
  36. #ifndef FWMENUS_K
  37. #include "FWMenus.k"
  38. #endif
  39.  
  40. // ----- ODUtil Includes -----
  41.  
  42. #ifndef FWORDCOL_H
  43. #include "FWOrdCol.h"
  44. #endif
  45.  
  46. // ----- OpenDoc Includes -----
  47.  
  48. #ifndef SOM_ODPart_xh
  49. #include <Part.xh>
  50. #endif
  51.  
  52. #ifndef SOM_ODDraft_xh
  53. #include <Draft.xh>
  54. #endif
  55.  
  56. #ifndef SOM_ODStorageUnit_xh
  57. #include <StorageU.xh>
  58. #endif
  59.  
  60. #ifndef SOM_ODSession_xh
  61. #include <ODSessn.xh>
  62. #endif
  63.  
  64. #ifndef SOM_ODWindowState_xh
  65. #include <WinStat.xh>
  66. #endif
  67.  
  68. // ----- Macintosh Includes -----
  69.  
  70. #if defined(FW_BUILD_MAC) && !defined(__TOOLUTILS__)
  71. #include <ToolUtils.h>
  72. #endif
  73.  
  74. //========================================================================================
  75. //    RunTime Info
  76. //========================================================================================
  77.  
  78. #ifdef FW_BUILD_MAC
  79. #pragma segment fwmenu
  80. #endif
  81.  
  82. //========================================================================================
  83. //    class FW_CMenuBar
  84. //========================================================================================
  85.  
  86. FW_DEFINE_AUTO(FW_CMenuBar)
  87.  
  88. //----------------------------------------------------------------------------------------
  89. //    FW_CMenuBar::FW_CMenuBar
  90. //----------------------------------------------------------------------------------------
  91.  
  92. FW_CMenuBar::FW_CMenuBar(Environment* ev, ODPart* thePart, FW_Instance partInstance) :
  93.     fODPart(thePart),
  94.     fPullDownMenuList(NULL),
  95.     fNextMenuID(FW_kFirstMenuID),
  96.     fPartInstance(partInstance)
  97. {
  98.     fODMenuBar = fODPart->GetStorageUnit(ev)->GetSession(ev)->GetWindowState(ev)->CopyBaseMenuBar(ev);
  99.     fPullDownMenuList = FW_NEW(FW_TOrderedCollection<FW_CPullDownMenu>, ());
  100. }
  101.  
  102. //----------------------------------------------------------------------------------------
  103. //    FW_CMenuBar::InitializeFromResource
  104. //----------------------------------------------------------------------------------------
  105.  
  106. void FW_CMenuBar::InitializeFromResource(Environment* ev, FW_ResourceID menuBarResourceID)
  107. {
  108.     // InitializeFromResource should only be called once, immediately after
  109.     // the menu bar is created, while the menu list is still empty.
  110.     // However, since it simply appends the menus to the end of the menubar,
  111.     // there may be no harm in calling it more than once.
  112.     // FW_ASSERT(fPullDownMenuList->Count() == 0);
  113.  
  114.     FW_TRY
  115.     {
  116.         FW_PSharedLibraryResourceFile resFile(ev, fPartInstance);
  117.         FW_PResource menuBarResource(ev, resFile, menuBarResourceID, FW_kMenuBarResourceType);
  118.         FW_PResourceSink sink(ev, menuBarResource);
  119.         FW_CReadableStream stream(sink);
  120.         InitializeFromStream(ev, stream);
  121.     }
  122.     FW_CATCH_BEGIN
  123.     FW_CATCH_REFERENCE(FW_XException, except)
  124.     {
  125.         // We use this try-catch block purely to warn about a common mistake.
  126.         // If one forgets to add the resource containing their menus to their project,
  127.         // or passes in the wrong menu id, the above code will throw an exception
  128.         // that probably won't get caught until the SOM entry point from OpenDoc.
  129.         // OpenDoc will display an error dialog that isn't particularly helpful
  130.         // in diagnosing the problem.
  131.         FW_DEBUG_MESSAGE("Failed to load menu resource.");
  132.         FW_PlatformError error = except.GetPlatformError();
  133.         FW_THROW_SAME();
  134.     }
  135.     FW_CATCH_END
  136. }
  137.  
  138. //----------------------------------------------------------------------------------------
  139. //    FW_CMenuBar::InitializeFromStream
  140. //----------------------------------------------------------------------------------------
  141.  
  142. void FW_CMenuBar::InitializeFromStream(Environment* ev, FW_CReadableStream& stream)
  143. {
  144.     // InitializeFromStream should only be called once, immediately after
  145.     // the menu bar is created, while the menu list is still empty.
  146.     // However, since it simply appends the menus to the end of the menubar,
  147.     // there may be no harm in calling it more than once.
  148.     // FW_ASSERT(fPullDownMenuList->Count() == 0);
  149.  
  150.     // This first FW_DO_NOT_DEAD_STRIP is a must, so it makes full sense to have it here.
  151.     FW_DO_NOT_DEAD_STRIP(FW_CPullDownMenu);
  152.     
  153.     // These aren't absolutely required, but it would be extremely rare to have menu
  154.     // items without Text and Separators, so for convenience we prevent them from
  155.     // being dead stripped in any part that initializes its menus from a stream (resource).
  156.     // However, the other kinds of menu items must be explicitly prevented from being
  157.     // deadstripped in every part that uses them.
  158.     FW_DO_NOT_DEAD_STRIP(FW_CTextItem);
  159.     FW_DO_NOT_DEAD_STRIP(FW_CSeparatorItem);
  160.  
  161.     stream >> fAboutString;
  162.  
  163.     short nMenus;
  164.     stream >> nMenus;
  165.     
  166.     while (nMenus-- > 0)
  167.     {
  168.         FW_CPullDownMenu* pullDownMenu;
  169.         FW_READ_DYNAMIC_OBJECT(stream, &pullDownMenu, FW_CPullDownMenu);
  170.         FW_ASSERT(pullDownMenu != 0);
  171.         AdoptMenuLast(ev, pullDownMenu);
  172.     }
  173. }
  174.  
  175. //----------------------------------------------------------------------------------------
  176. //    FW_CMenuBar::~FW_CMenuBar
  177. //----------------------------------------------------------------------------------------
  178.  
  179. FW_CMenuBar::~FW_CMenuBar()
  180. {
  181.     FW_SOMEnvironment ev;
  182.     
  183.     if (fPullDownMenuList)
  184.         DeleteAll(ev);
  185.  
  186.     if (fODMenuBar)
  187.         fODMenuBar->Release(ev);
  188. }
  189.  
  190. //----------------------------------------------------------------------------------------
  191. //    FW_CMenuBar::AdoptMenuFirst
  192. //----------------------------------------------------------------------------------------
  193.  
  194. void FW_CMenuBar::AdoptMenuFirst(Environment* ev, FW_CPullDownMenu* menu)
  195. {
  196.     FW_ASSERT(menu != NULL);
  197.     
  198.     FW_CPullDownMenu* first = (FW_CPullDownMenu*)fPullDownMenuList->First();
  199.     fPullDownMenuList->AddFirst(menu);
  200.     
  201.     ODMenuID beforeID = first == NULL ? -1 : first->GetMenuID(ev);    
  202.     menu->PrivAttachedToMenuBar(ev, fODPart, this, beforeID);
  203. }
  204.  
  205. //----------------------------------------------------------------------------------------
  206. //    FW_CMenuBar::AdoptMenuLast
  207. //----------------------------------------------------------------------------------------
  208.  
  209. void FW_CMenuBar::AdoptMenuLast(Environment* ev, FW_CPullDownMenu* menu)
  210. {
  211.     FW_ASSERT(menu != NULL);
  212.     
  213.     fPullDownMenuList->AddLast(menu);    
  214.     menu->PrivAttachedToMenuBar(ev, fODPart, this, -1);
  215. }
  216.  
  217. //----------------------------------------------------------------------------------------
  218. //    FW_CMenuBar::AdoptMenuBefore
  219. //----------------------------------------------------------------------------------------
  220.  
  221. void FW_CMenuBar::AdoptMenuBefore(Environment* ev, FW_CPullDownMenu* menu, FW_CPullDownMenu* beforeMenu)
  222. {
  223.     FW_ASSERT(menu != NULL);
  224.  
  225.     if (beforeMenu == NULL)
  226.         AdoptMenuFirst(ev, menu);
  227.     else
  228.     {
  229.         fPullDownMenuList->AddBefore(beforeMenu, menu);
  230.         menu->PrivAttachedToMenuBar(ev, fODPart, this, beforeMenu->GetMenuID(ev));
  231.     }
  232. }
  233.  
  234. //----------------------------------------------------------------------------------------
  235. //    FW_CMenuBar::AdoptMenuAfter
  236. //----------------------------------------------------------------------------------------
  237.  
  238. void FW_CMenuBar::AdoptMenuAfter(Environment* ev, FW_CPullDownMenu* menu, FW_CPullDownMenu* afterMenu)
  239. {
  240.     FW_ASSERT(menu != NULL);
  241.  
  242.     if (afterMenu == NULL)
  243.         AdoptMenuLast(ev, menu);
  244.     else
  245.     {
  246.         FW_CPullDownMenu* next = (FW_CPullDownMenu*)fPullDownMenuList->After(afterMenu);
  247.         fPullDownMenuList->AddAfter(afterMenu, menu);
  248.         ODMenuID beforeID = next == NULL ? -1 : next->GetMenuID(ev);    
  249.         menu->PrivAttachedToMenuBar(ev, fODPart, this, beforeID);
  250.     }
  251. }
  252.  
  253. //----------------------------------------------------------------------------------------
  254. //    FW_CMenuBar::DeleteMenu
  255. //----------------------------------------------------------------------------------------
  256.  
  257. void FW_CMenuBar::DeleteMenu(Environment* ev, FW_CPullDownMenu* menuToDelete)
  258. {
  259.     FW_ASSERT(menuToDelete != NULL);
  260.  
  261.     DetachMenu(ev, menuToDelete);
  262.     delete menuToDelete;
  263. }
  264.  
  265. //----------------------------------------------------------------------------------------
  266. //    FW_CMenuBar::DeleteAll
  267. //----------------------------------------------------------------------------------------
  268.  
  269. void FW_CMenuBar::DeleteAll(Environment* ev)
  270. {
  271.     FW_CPullDownMenu *menu;
  272.     while ((menu = fPullDownMenuList->First()) != NULL)
  273.     {
  274.         DeleteMenu(ev, menu);
  275.     }
  276. }
  277.  
  278. //----------------------------------------------------------------------------------------
  279. //    FW_CMenuBar::RemoveItem
  280. //----------------------------------------------------------------------------------------
  281.  
  282. void FW_CMenuBar::RemoveItem(Environment* ev, ODCommandID commandID)
  283. {
  284.     FW_CMenuItem* item = this->GetMenuItemFromCommand(ev, commandID);
  285.     FW_ASSERT(item);
  286.     
  287.     FW_CPullDownMenu* menu = item->GetOwnerMenu(ev);
  288.     menu->RemoveItem(ev, item->GetIndex(ev));
  289. }
  290.  
  291. //----------------------------------------------------------------------------------------
  292. //    FW_CMenuBar::DetachMenu
  293. //----------------------------------------------------------------------------------------
  294.  
  295. void FW_CMenuBar::DetachMenu(Environment* ev, FW_CPullDownMenu* menuToDetach)
  296. {
  297.     FW_ASSERT(menuToDetach != NULL);
  298.     
  299.     fODMenuBar->RemoveMenu(ev, menuToDetach->GetMenuID(ev));
  300.     
  301.     fPullDownMenuList->Remove(menuToDetach);
  302.     menuToDetach->PrivDetachedFromMenuBar(ev, this);
  303. }
  304.  
  305. //----------------------------------------------------------------------------------------
  306. //    FW_CMenuBar::GetMenuKey
  307. //----------------------------------------------------------------------------------------
  308.  
  309. FW_MenuKey FW_CMenuBar::GetMenuKey(Environment* ev, ODCommandID cmdNumber) const
  310. {
  311. #ifdef FW_BUILD_MAC
  312.     FW_MenuKey menuKey;
  313.     
  314.     ODMenuID menuID;
  315.     ODMenuItemID menuItem;
  316.     fODMenuBar->GetMenuAndItem(ev, cmdNumber, &menuID, &menuItem);
  317.     
  318.     ::GetItemCmd(GetMenuHandle(menuID), menuItem, &menuKey);
  319.     return menuKey;
  320. #endif
  321.  
  322. #ifdef FW_BUILD_WIN
  323.     return 0;                    // [HLX] no way yet to parse accelerator table
  324. #endif
  325. }
  326.  
  327. //----------------------------------------------------------------------------------------
  328. //    FW_CMenuBar::AcquireODMenuBar
  329. //----------------------------------------------------------------------------------------
  330.  
  331. ODMenuBar* FW_CMenuBar::AcquireODMenuBar(Environment* ev) const
  332. {
  333. #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
  334.     fODMenuBar->Acquire(ev);
  335. #else
  336.     fODMenuBar->IncrementRefCount(ev);
  337. #endif
  338.     return fODMenuBar;
  339. }
  340.  
  341. //----------------------------------------------------------------------------------------
  342. //    FW_CMenuBar::FindMenuWithID
  343. //----------------------------------------------------------------------------------------
  344.  
  345. FW_CPullDownMenu* FW_CMenuBar::FindMenuWithID(Environment* ev, ODMenuID menuID) const
  346. {
  347.     // ----- Search the top level first -----
  348.     FW_TOrderedCollectionIterator<FW_CPullDownMenu> ite(fPullDownMenuList);
  349.     FW_CPullDownMenu* pullDownMenu;
  350.     for (pullDownMenu = ite.First(); ite.IsNotComplete(); pullDownMenu = ite.Next())
  351.     {
  352.         if (pullDownMenu->GetMenuID(ev) == menuID)
  353.             return pullDownMenu;
  354.     }
  355.     
  356.     // ----- Then search subMenus -----
  357.     for (pullDownMenu = ite.First(); ite.IsNotComplete(); pullDownMenu = ite.Next())
  358.     {
  359.         FW_CPullDownMenu* menu = pullDownMenu->PrivFindMenuWithID(ev, menuID);
  360.         if (menu)
  361.             return menu;
  362.     }
  363.     
  364.     return NULL;
  365. }
  366.  
  367. #ifdef FW_BUILD_MAC
  368. //----------------------------------------------------------------------------------------
  369. //    FW_CMenuBar::MacEnableMenuBar
  370. //----------------------------------------------------------------------------------------
  371. //    This is specific for modal dialogs on the Mac
  372.  
  373. void FW_CMenuBar::MacEnableMenuBar(Environment* ev, FW_Boolean enable)
  374. {
  375.     // ----- Apple & OpenDoc Menus -----
  376.     fODMenuBar->EnableCommand(ev, kODCommandAppleMenu, enable);
  377.     fODMenuBar->EnableCommand(ev, kODCommandEditMenu, enable);
  378.     fODMenuBar->EnableCommand(ev, kODCommandDocumentMenu, enable);
  379.  
  380.     // ----- Then custom menus -----
  381.     FW_TOrderedCollectionIterator<FW_CPullDownMenu> ite(fPullDownMenuList);
  382.     for (FW_CPullDownMenu* pullDownMenu = ite.First(); ite.IsNotComplete(); pullDownMenu = ite.Next())
  383.     {
  384.         if (enable)
  385.             ::EnableItem(GetMenuHandle(pullDownMenu->GetMenuID(ev)), 0);
  386.         else
  387.             ::DisableItem(GetMenuHandle(pullDownMenu->GetMenuID(ev)), 0);
  388.     }
  389.     
  390.     ::InvalMenuBar();
  391. }
  392. #endif
  393.  
  394. //----------------------------------------------------------------------------------------
  395. //    FW_CMenuBar::EnableCommand
  396. //----------------------------------------------------------------------------------------
  397.  
  398. void FW_CMenuBar::EnableCommand(Environment* ev, ODCommandID cmdNumber, FW_Boolean enable)
  399. {
  400.     fODMenuBar->EnableCommand(ev, cmdNumber, enable);
  401.  
  402. #ifdef FW_BUILD_MAC
  403.     PrivMacEnableParentItem(ev, cmdNumber);
  404. #endif
  405. }
  406.  
  407. #ifdef FW_BUILD_MAC
  408. //----------------------------------------------------------------------------------------
  409. //    FW_CMenuBar::PrivMacEnableParentItem
  410. //----------------------------------------------------------------------------------------
  411.  
  412. void FW_CMenuBar::PrivMacEnableParentItem(Environment* ev, ODCommandID cmdNumber)
  413. {
  414.     ODMenuID menuID;
  415.     ODMenuItemID menuItem;
  416.     
  417.     fODMenuBar->GetMenuAndItem(ev, cmdNumber, &menuID, &menuItem);
  418.     
  419.     FW_CPullDownMenu* menu = this->FindMenuWithID(ev, menuID);
  420.     if (menu == NULL)
  421.         return;
  422.         
  423.     FW_CMenuItem* parentItem = menu->GetParentMenuItem(ev);
  424.  
  425.     while (parentItem != NULL)                    // enable/disable parent menu
  426.     {    
  427.         ODPlatformMenu platformMenu = menu->GetPlatformMenu(ev);
  428.         long flags = (*platformMenu)->enableFlags;
  429.         
  430.         if ((flags & 0xFFFFFFFE) != 0)            // If any items enabled,
  431.             flags |= 0x00000001;                // enable top level item
  432.         else                                    // No items enabled,
  433.             flags = 0x00000000;                    // disable top level item
  434.         
  435.         if ((flags & 0x00000001) != ((*platformMenu)->enableFlags & 0x00000001))
  436.         {
  437.             (*platformMenu)->enableFlags = flags;
  438.         }
  439.         
  440.         menu = parentItem->GetOwnerMenu(ev);
  441.         ODPlatformMenu parentMenu = menu->GetPlatformMenu(ev);
  442.         if ((flags & 0xFFFFFFFE) != 0)    // if any items enabled
  443.             ::EnableItem(parentMenu, parentItem->GetIndex(ev));
  444.         else
  445.             ::DisableItem(parentMenu, parentItem->GetIndex(ev));
  446.     
  447.         // Check parent's parent
  448.         parentItem = menu->GetParentMenuItem(ev);
  449.     }
  450. }
  451. #endif
  452.  
  453. //----------------------------------------------------------------------------------------
  454. //    FW_CMenuBar::GetMenuItemFromCommand
  455. //----------------------------------------------------------------------------------------
  456.  
  457. FW_CMenuItem* FW_CMenuBar::GetMenuItemFromCommand(Environment* ev, ODCommandID cmdNumber) const
  458. {
  459.     FW_TOrderedCollectionIterator<FW_CPullDownMenu> ite(fPullDownMenuList);
  460.     for (FW_CPullDownMenu* pullDownMenu = ite.First(); ite.IsNotComplete(); pullDownMenu = ite.Next())
  461.     {
  462.         FW_CMenuItem* menuItem = pullDownMenu->PrivGetMenuItem(ev, cmdNumber);
  463.         if (menuItem != NULL)
  464.             return menuItem;
  465.     }    
  466.     return NULL;    
  467. }
  468.  
  469. //----------------------------------------------------------------------------------------
  470. //    FW_CMenuBar::ToggleItem
  471. //----------------------------------------------------------------------------------------
  472.  
  473. void FW_CMenuBar::ToggleItem(Environment* ev, 
  474.                             ODCommandID cmdNumber, 
  475.                             FW_Boolean toggleState)
  476. {
  477.     FW_CMenuItem* menuItem = GetMenuItemFromCommand(ev, cmdNumber);
  478.     FW_ASSERT(menuItem != NULL);
  479.     
  480. #ifdef FW_DEBUG
  481.     FW_CToggleItem* toggleItem = FW_DYNAMIC_CAST(FW_CToggleItem, menuItem);
  482.     FW_ASSERT(toggleItem);
  483.     toggleItem->ToggleItem(ev, toggleState);
  484. #else
  485.     ((FW_CToggleItem*)menuItem)->ToggleItem(ev, toggleState);
  486. #endif
  487. }
  488.  
  489. //----------------------------------------------------------------------------------------
  490. //    FW_CMenuBar::DisableAll
  491. //----------------------------------------------------------------------------------------
  492.  
  493. void FW_CMenuBar::DisableAll(Environment* ev)
  494. {
  495.     FW_TOrderedCollectionIterator<FW_CPullDownMenu> ite(fPullDownMenuList);
  496.     for (FW_CPullDownMenu* pullDownMenu = ite.First(); ite.IsNotComplete(); pullDownMenu = ite.Next())
  497.     {
  498.         pullDownMenu->DisableAll(ev);
  499.     }    
  500. }
  501.  
  502. //----------------------------------------------------------------------------------------
  503. //    FW_CMenuBar::EnableAll
  504. //----------------------------------------------------------------------------------------
  505.  
  506. void FW_CMenuBar::EnableAll(Environment* ev)
  507. {
  508.     FW_TOrderedCollectionIterator<FW_CPullDownMenu> ite(fPullDownMenuList);
  509.     for (FW_CPullDownMenu* pullDownMenu = ite.First(); ite.IsNotComplete(); pullDownMenu = ite.Next())
  510.     {
  511.         pullDownMenu->EnableAll(ev);
  512.     }    
  513. }
  514.  
  515. //----------------------------------------------------------------------------------------
  516. //    FW_CMenuBar::CheckCommand
  517. //----------------------------------------------------------------------------------------
  518.  
  519. void FW_CMenuBar::CheckCommand(Environment* ev, ODCommandID cmdNumber, FW_Boolean check)
  520. {
  521.     fODMenuBar->CheckCommand(ev, cmdNumber, check);
  522. }
  523.  
  524. //----------------------------------------------------------------------------------------
  525. //    FW_CMenuBar::EnableAndCheckCommand
  526. //----------------------------------------------------------------------------------------
  527.  
  528. void FW_CMenuBar::EnableAndCheckCommand(Environment* ev, ODCommandID cmdNumber, FW_Boolean enable, FW_Boolean check)
  529. {
  530.     fODMenuBar->EnableAndCheckCommand(ev, cmdNumber, enable, check);
  531.  
  532. #ifdef FW_BUILD_MAC
  533.     PrivMacEnableParentItem(ev, cmdNumber);
  534. #endif
  535. }
  536.  
  537. //----------------------------------------------------------------------------------------
  538. //    FW_CMenuBar::EnableAndToggleCommand
  539. //----------------------------------------------------------------------------------------
  540.  
  541. void FW_CMenuBar::EnableAndToggleCommand(Environment* ev, ODCommandID cmdNumber, FW_Boolean enable, FW_Boolean toggleState)
  542. {
  543.     EnableCommand(ev, cmdNumber, enable);
  544.     ToggleItem(ev, cmdNumber, toggleState);
  545. }
  546.  
  547. //----------------------------------------------------------------------------------------
  548. //    FW_CMenuBar::SetItemString
  549. //----------------------------------------------------------------------------------------
  550.  
  551. void FW_CMenuBar::SetItemString(Environment* ev, ODCommandID commandID, const FW_CString& itemString)
  552. {
  553.     fODMenuBar->SetItemString(ev, commandID, itemString.RevealODIText());
  554. }
  555.  
  556. //----------------------------------------------------------------------------------------
  557. //    FW_CMenuBar::GetItemString
  558. //----------------------------------------------------------------------------------------
  559.  
  560. void FW_CMenuBar::GetItemString(Environment* ev, ODCommandID commandID, FW_CString& itemString) const
  561. {
  562.     ODIText intlText;
  563.     fODMenuBar->GetItemString(ev, commandID, &intlText);
  564.     itemString = &intlText;
  565. }
  566.  
  567. //----------------------------------------------------------------------------------------
  568. //    FW_CMenuBar::GetAboutString
  569. //----------------------------------------------------------------------------------------
  570. FW_CString FW_CMenuBar::GetAboutString(Environment*) const
  571. {
  572.     return fAboutString;
  573. }
  574.  
  575. //----------------------------------------------------------------------------------------
  576. //    FW_CMenuBar::SetMenuKey
  577. //----------------------------------------------------------------------------------------
  578.  
  579. void FW_CMenuBar::SetMenuKey(Environment* ev, ODCommandID cmdNumber, FW_MenuKey menuKey)
  580. {
  581. #ifdef FW_BUILD_MAC
  582.     ODMenuID menuID;
  583.     ODMenuItemID menuItem;
  584.     fODMenuBar->GetMenuAndItem(ev, cmdNumber, &menuID, &menuItem);
  585.     MenuHandle menuHandle = ::GetMenuHandle(menuID);
  586.     FW_ASSERT(menuHandle);
  587.  
  588.     // Check for an existing key code, or other code ($1B submenu; $1C script code; $1D, $1E icon)
  589.     FW_MenuKey currentKey;
  590.     ::GetItemCmd(menuHandle, menuItem, ¤tKey);
  591.  
  592.     // If the current value is a special code, don't change it
  593.     if (currentKey == FW_kNoKeyEquivalent || currentKey > 32)
  594.         ::SetItemCmd(menuHandle, menuItem, menuKey & FW_kPrivMacMenuKeyCharMask);
  595. #endif
  596.  
  597. #ifdef FW_BUILD_WIN
  598.     // [MEB] Not yet implemented
  599.     FW_UNUSED(ev);
  600.     FW_UNUSED(cmdNumber);
  601.     FW_UNUSED(menuKey);
  602. #endif
  603. }
  604.